// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   GrWorkCheckPro.java

package com.oa.hr.wkCheck;

import com.oa.database.DataConn;
import com.oa.sysmanage.Position;
import java.io.PrintStream;
import java.sql.*;

public class GrWorkCheckPro
{

    private DataConn dataConn;
    private Connection conn;
    private int blYgid;
    private String blYgxm;

    public GrWorkCheckPro(DataConn dataConn)
    {
        this.dataConn = null;
        conn = null;
        blYgid = 0;
        blYgxm = null;
        this.dataConn = dataConn;
        conn = dataConn.getConnection();
    }

    public int getJsidBySpjd(int jdid)
    {
        int jsid = 0;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        String sqlStr = "select JSID from OA_YG_GRJH_SPJD  where JDID = ? ";
        try
        {
            pstmt = conn.prepareStatement(sqlStr);
            pstmt.setInt(1, jdid);
            rs = pstmt.executeQuery();
            if(rs.next())
                jsid = rs.getInt(1);
            rs.close();
            pstmt.close();
        }
        catch(SQLException sqle)
        {
            sqle.printStackTrace();
        }
        return jsid;
    }

    public int getJsidByKhjd(int jdid)
    {
        int jsid = 0;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        String sqlStr = "select JSID from OA_YG_GRJH_KHJD  where JDID = ? ";
        try
        {
            pstmt = conn.prepareStatement(sqlStr);
            pstmt.setInt(1, jdid);
            rs = pstmt.executeQuery();
            if(rs.next())
                jsid = rs.getInt(1);
            rs.close();
            pstmt.close();
        }
        catch(SQLException sqle)
        {
            sqle.printStackTrace();
        }
        return jsid;
    }

    public int getYgid(int zwid, int jsid)
    {
        int ygid = 0;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        String sqlStr = "select ZWID from OA_ZWB  where JSID = ? and zwid = ?";
        try
        {
            pstmt = conn.prepareStatement(sqlStr);
            String zwidStr = Integer.toString(zwid);
            DataConn dataConn1 = new DataConn();
            Position position = new Position(dataConn1);
            boolean ifFind = false;
            for(zwidStr = position.getParentPostionId(zwidStr); !zwidStr.equals("") && !ifFind; rs.close())
            {
                pstmt.setInt(1, jsid);
                pstmt.setInt(2, Integer.parseInt(zwidStr));
                rs = pstmt.executeQuery();
                if(rs.next())
                {
                    ifFind = true;
                    break;
                }
                zwidStr = position.getParentPostionId(zwidStr);
            }

            pstmt.close();
            if(ifFind)
            {
                sqlStr = "select YGID from OA_YGB where state=1 AND  ZWID like '%," + zwidStr + ",%'";
                pstmt = conn.prepareStatement(sqlStr);
                rs = pstmt.executeQuery();
                if(rs.next())
                    ygid = rs.getInt(1);
                rs.close();
                pstmt.close();
            }
            dataConn1.close();
        }
        catch(SQLException sqle)
        {
            sqle.printStackTrace();
        }
        return ygid;
    }

    public double makeZf(int JHID)
    {
        double ZF = 0.0D;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        String sqlStr = "select ZPF,ZGPF,BZPF,FGPF,KQF from OA_YG_GRJH  where JHID = ? ";
        try
        {
            pstmt = conn.prepareStatement(sqlStr);
            pstmt.setInt(1, JHID);
            rs = pstmt.executeQuery();
            float ZPF = 0.0F;
            float ZGPF = 0.0F;
            float BZPF = 0.0F;
            float FGPF = 0.0F;
            float KQF = 0.0F;
            if(rs.next())
            {
                ZPF = rs.getFloat(1);
                ZGPF = rs.getFloat(2);
                BZPF = rs.getFloat(3);
                FGPF = rs.getFloat(4);
                KQF = rs.getFloat(5);
            }
            rs.close();
            pstmt.close();
            ZF = ((double)ZGPF * 0.40000000000000002D + (double)BZPF * 0.29999999999999999D + (double)FGPF * 0.20000000000000001D + (double)ZPF * 0.10000000000000001D) * 0.90000000000000002D + (double)KQF * 0.10000000000000001D;
            sqlStr = "update OA_YG_GRJH set ZF = ?";
            pstmt = conn.prepareStatement(sqlStr);
            pstmt.setDouble(1, ZF);
            pstmt.executeUpdate();
            pstmt.close();
        }
        catch(SQLException sqle)
        {
            sqle.printStackTrace();
        }
        return ZF;
    }

    public static void main(String args[])
    {
        DataConn dataConn = new DataConn();
        GrWorkCheckPro pro = new GrWorkCheckPro(dataConn);
        System.out.println(pro.getYgid(100, 70));
        System.out.println(pro.makeZf(2));
    }
}
